<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/loadcss">
</head>

<body>
    <div id="whole">
        <div id="box">
            <div id="main">
                <h1>欢迎进入验证码管理系统！</h1>
                <div id="check">
                    <input placeholder="请输入用户名" type="text" id="inp1" />
                    <input placeholder="请输入密码" type="password" id="inp2" />
                </div>
                <button>
                    <span class="button-content">
                        <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
                            <path d="M0 0H24V24H0z" fill="none"></path>
                            <path
                                d="M12.001 4.529c2.349-2.109 5.979-2.039 8.242.228 2.262 2.268 2.34 5.88.236 8.236l-8.48 8.492-8.478-8.492c-2.104-2.356-2.025-5.974.236-8.236 2.265-2.264 5.888-2.34 8.244-.228z"
                                fill="currentColor"></path>
                        </svg>
                        <span>登录</span>
                    </span>
                </button>
            </div>
        </div>
    </div>

</body>
<script>
    var btn = document.getElementsByTagName('button')[0];
    var inp1 = document.getElementById('inp1');
    var inp2 = document.getElementById('inp2');

    btn.onclick = function () {
        fetch('/admin/login', {
            method: 'post',
            body: JSON.stringify({ username: inp1.value, code: inp2.value })
        }).then(res => res.text()).then(res => {
            console.log(res)
            if (res == 'false') {
                alert('登陆失败')
            } else {
                window.location.href = 'http://localhost:1234/index'
            }
        })
    }
</script>

</html>